package com.heima.user.utils;

import com.heima.model.user.entity.ApUser;

public class AppUserThreadLocalUtil {
    private static final ThreadLocal<ApUser> TL=new ThreadLocal<>();

    /**
     * 保存用户信息到Thread Local
     * @param apUser
     */
    public static void set(ApUser apUser){
        if (apUser!=null){
            TL.set(apUser);
        }
    }

    /**
     * 从Thread Local获取用户信息
     * @return
     */
    public static ApUser get(){
        return TL.get();
    }

    public static void remove(){
        TL.remove();
    }
}
